const fs = require("fs")
const esprima = require("esprima")
const estraverse = require("estraverse")
const escodegen = require("escodegen")
const iconv = require("iconv-lite")
const base_ast = require("../../tools/es_ast_tool")
const {convertNodesIntoNode} = require("jsdom/lib/jsdom/living/node");

// var ast = base_ast.get_ast_by_file("./PD18EXRU.js")

function de_parse(file){
    var ast = base_ast.get_ast_by_file(file);
    estraverse.replace(ast,{
        enter(node, parent){
            if(node.type==="MemberExpression" && node.object.name==="RK"&&parent.type==="CallExpression"){
                var val = eval(escodegen.generate(parent));
                console.log(val);
            }
        }
    })
//     var new_code = escodegen.generate(ast);
// // console.log(new_code);
//     fs.writeFile("./de.js", new_code, (err) => {});
}

module.exports = {
    de_parse
}